package controller.android;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.BookingDTO;
import model.UserDTO;
import model.search.BookingSearchDTO;
import bizlogic.BookingManager;

/**
 * Servlet implementation class BookingHistoryServlet
 */
@WebServlet("/BookingHistoryServlet")
public class BookingHistoryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BookingHistoryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String id = request.getParameter("id");
		ArrayList<BookingDTO> bList = new ArrayList<BookingDTO>();

		ArrayList<String> status = new ArrayList<String>();
		status.add("Approve");
		status.add("Reject");
		status.add("Cancel");
		status.add("Delete");
		

		BookingSearchDTO b = new BookingSearchDTO();
		b.setUserId(id);
		b.setStatus(status);

		BookingManager bm = new BookingManager();
		bList = bm.findBookingByCriteria(b);

		PrintWriter out = response.getWriter();

		

		for (int i = 0; i < bList.size(); i++) {			
			out.println( bList.get(i).getId());
			out.println( bList.get(i).getFacilityName());
			out.println( bList.get(i).getStartDate());
			out.println( bList.get(i).getEndDate());
			out.println( bList.get(i).getReason());
			out.println( bList.get(i).getEmergency());
			out.println( bList.get(i).getValidateBy());
			out.println( bList.get(i).getValidateOn());
			out.println( bList.get(i).getContactDetail());
			out.println( bList.get(i).getStatus());
			
		}
		

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
